3.37 \(\int \frac{\tan ^2(c+d x) (A+B \tan (c+d x))}{a+i a \tan (c+d x)} \, dx\)

Optimal. Leaf size=101 \[ \frac{(-B+i A) \tan ^2(c+d x)}{2 d (a+i a \tan (c+d x))}-\frac{(A+3 i B) \tan (c+d x)}{2 a d}+\frac{(-B+i A) \log (\cos (c+d x))}{a d}+\frac{x (A+3 i B)}{2 a} \]

[Out]

((A + (3*I)*B)*x)/(2*a) + ((I*A - B)*Log[Cos[c + d*x]])/(a*d) - ((A + (3*I)*B)*Tan[c + d*x])/(2*a*d) + ((I*A -
 B)*Tan[c + d*x]^2)/(2*d*(a + I*a*Tan[c + d*x]))

________________________________________________________________________________________

Rubi [A]  time = 0.124644, antiderivative size = 101, normalized size of antiderivative = 1., number of steps used = 3, number of rules used = 3, integrand size = 34, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.088, Rules used = {3595, 3525, 3475} \[ \frac{(-B+i A) \tan ^2(c+d x)}{2 d (a+i a \tan (c+d x))}-\frac{(A+3 i B) \tan (c+d x)}{2 a d}+\frac{(-B+i A) \log (\cos (c+d x))}{a d}+\frac{x (A+3 i B)}{2 a} \]

Antiderivative was successfully verified.

[In]

Int[(Tan[c + d*x]^2*(A + B*Tan[c + d*x]))/(a + I*a*Tan[c + d*x]),x]

[Out]

((A + (3*I)*B)*x)/(2*a) + ((I*A - B)*Log[Cos[c + d*x]])/(a*d) - ((A + (3*I)*B)*Tan[c + d*x])/(2*a*d) + ((I*A -
 B)*Tan[c + d*x]^2)/(2*d*(a + I*a*Tan[c + d*x]))

Rule 3595

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_
.) + (f_.)*(x_)])^(n_), x_Symbol] :> -Simp[((A*b - a*B)*(a + b*Tan[e + f*x])^m*(c + d*Tan[e + f*x])^n)/(2*a*f*
m), x] + Dist[1/(2*a^2*m), Int[(a + b*Tan[e + f*x])^(m + 1)*(c + d*Tan[e + f*x])^(n - 1)*Simp[A*(a*c*m + b*d*n
) - B*(b*c*m + a*d*n) - d*(b*B*(m - n) - a*A*(m + n))*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f, A,
B}, x] && NeQ[b*c - a*d, 0] && EqQ[a^2 + b^2, 0] && LtQ[m, 0] && GtQ[n, 0]

Rule 3525

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c - b
*d)*x, x] + (Dist[b*c + a*d, Int[Tan[e + f*x], x], x] + Simp[(b*d*Tan[e + f*x])/f, x]) /; FreeQ[{a, b, c, d, e
, f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]

Rule 3475

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> -Simp[Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps

\begin{align*} \int \frac{\tan ^2(c+d x) (A+B \tan (c+d x))}{a+i a \tan (c+d x)} \, dx &=\frac{(i A-B) \tan ^2(c+d x)}{2 d (a+i a \tan (c+d x))}-\frac{\int \tan (c+d x) (2 a (i A-B)+a (A+3 i B) \tan (c+d x)) \, dx}{2 a^2}\\ &=\frac{(A+3 i B) x}{2 a}-\frac{(A+3 i B) \tan (c+d x)}{2 a d}+\frac{(i A-B) \tan ^2(c+d x)}{2 d (a+i a \tan (c+d x))}-\frac{(i A-B) \int \tan (c+d x) \, dx}{a}\\ &=\frac{(A+3 i B) x}{2 a}+\frac{(i A-B) \log (\cos (c+d x))}{a d}-\frac{(A+3 i B) \tan (c+d x)}{2 a d}+\frac{(i A-B) \tan ^2(c+d x)}{2 d (a+i a \tan (c+d x))}\\ \end{align*}

Mathematica [B]  time = 4.35677, size = 240, normalized size = 2.38 \[ \frac{(\cos (d x)+i \sin (d x)) (A+B \tan (c+d x)) \left ((B-i A) (\cos (c)-i \sin (c)) \cos (2 d x)+2 d x (A+3 i B) (\cos (c)+i \sin (c))+(A+i B) (-\cos (c)+i \sin (c)) \sin (2 d x)+2 i (A+i B) (\cos (c)+i \sin (c)) \log \left (\cos ^2(c+d x)\right )+4 (A+i B) (\cos (c)+i \sin (c)) \tan ^{-1}(\tan (d x))+4 d x (A+i B) \tan (c) (\sin (c)-i \cos (c))-4 A d x \sec (c)-4 i B d x \sec (c)+4 B (\tan (c)-i) \sin (d x) \sec (c+d x)\right )}{4 d (a+i a \tan (c+d x)) (A \cos (c+d x)+B \sin (c+d x))} \]

Antiderivative was successfully verified.

[In]

Integrate[(Tan[c + d*x]^2*(A + B*Tan[c + d*x]))/(a + I*a*Tan[c + d*x]),x]

[Out]

((Cos[d*x] + I*Sin[d*x])*(-4*A*d*x*Sec[c] - (4*I)*B*d*x*Sec[c] + ((-I)*A + B)*Cos[2*d*x]*(Cos[c] - I*Sin[c]) +
 2*(A + (3*I)*B)*d*x*(Cos[c] + I*Sin[c]) + 4*(A + I*B)*ArcTan[Tan[d*x]]*(Cos[c] + I*Sin[c]) + (2*I)*(A + I*B)*
Log[Cos[c + d*x]^2]*(Cos[c] + I*Sin[c]) + (A + I*B)*(-Cos[c] + I*Sin[c])*Sin[2*d*x] + 4*(A + I*B)*d*x*((-I)*Co
s[c] + Sin[c])*Tan[c] + 4*B*Sec[c + d*x]*Sin[d*x]*(-I + Tan[c]))*(A + B*Tan[c + d*x]))/(4*d*(A*Cos[c + d*x] +
B*Sin[c + d*x])*(a + I*a*Tan[c + d*x]))

________________________________________________________________________________________

Maple [A]  time = 0.028, size = 137, normalized size = 1.4 \begin{align*}{\frac{-iB\tan \left ( dx+c \right ) }{ad}}-{\frac{A}{2\,ad \left ( \tan \left ( dx+c \right ) -i \right ) }}-{\frac{{\frac{i}{2}}B}{ad \left ( \tan \left ( dx+c \right ) -i \right ) }}-{\frac{{\frac{3\,i}{4}}\ln \left ( \tan \left ( dx+c \right ) -i \right ) A}{ad}}+{\frac{5\,\ln \left ( \tan \left ( dx+c \right ) -i \right ) B}{4\,ad}}-{\frac{B\ln \left ( \tan \left ( dx+c \right ) +i \right ) }{4\,ad}}-{\frac{{\frac{i}{4}}A\ln \left ( \tan \left ( dx+c \right ) +i \right ) }{ad}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c)),x)

[Out]

-I/d/a*B*tan(d*x+c)-1/2/d/a/(tan(d*x+c)-I)*A-1/2*I/d/a/(tan(d*x+c)-I)*B-3/4*I/d/a*ln(tan(d*x+c)-I)*A+5/4/d/a*l
n(tan(d*x+c)-I)*B-1/4/d/a*B*ln(tan(d*x+c)+I)-1/4*I/d/a*A*ln(tan(d*x+c)+I)

________________________________________________________________________________________

Maxima [F(-2)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: RuntimeError} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c)),x, algorithm="maxima")

[Out]

Exception raised: RuntimeError

________________________________________________________________________________________

Fricas [A]  time = 1.4707, size = 362, normalized size = 3.58 \begin{align*} \frac{2 \,{\left (3 \, A + 5 i \, B\right )} d x e^{\left (4 i \, d x + 4 i \, c\right )} +{\left (2 \,{\left (3 \, A + 5 i \, B\right )} d x - i \, A + 9 \, B\right )} e^{\left (2 i \, d x + 2 i \, c\right )} +{\left ({\left (4 i \, A - 4 \, B\right )} e^{\left (4 i \, d x + 4 i \, c\right )} +{\left (4 i \, A - 4 \, B\right )} e^{\left (2 i \, d x + 2 i \, c\right )}\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) - i \, A + B}{4 \,{\left (a d e^{\left (4 i \, d x + 4 i \, c\right )} + a d e^{\left (2 i \, d x + 2 i \, c\right )}\right )}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c)),x, algorithm="fricas")

[Out]

1/4*(2*(3*A + 5*I*B)*d*x*e^(4*I*d*x + 4*I*c) + (2*(3*A + 5*I*B)*d*x - I*A + 9*B)*e^(2*I*d*x + 2*I*c) + ((4*I*A
 - 4*B)*e^(4*I*d*x + 4*I*c) + (4*I*A - 4*B)*e^(2*I*d*x + 2*I*c))*log(e^(2*I*d*x + 2*I*c) + 1) - I*A + B)/(a*d*
e^(4*I*d*x + 4*I*c) + a*d*e^(2*I*d*x + 2*I*c))

________________________________________________________________________________________

Sympy [A]  time = 7.31978, size = 150, normalized size = 1.49 \begin{align*} \frac{2 B e^{- 2 i c}}{a d \left (e^{2 i d x} + e^{- 2 i c}\right )} + \frac{\left (\begin{cases} 3 A x e^{2 i c} - \frac{i A e^{- 2 i d x}}{2 d} + 5 i B x e^{2 i c} + \frac{B e^{- 2 i d x}}{2 d} & \text{for}\: d \neq 0 \\x \left (3 A e^{2 i c} - A + 5 i B e^{2 i c} - i B\right ) & \text{otherwise} \end{cases}\right ) e^{- 2 i c}}{2 a} + \frac{\left (i A - B\right ) \log{\left (e^{2 i d x} + e^{- 2 i c} \right )}}{a d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)**2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c)),x)

[Out]

2*B*exp(-2*I*c)/(a*d*(exp(2*I*d*x) + exp(-2*I*c))) + Piecewise((3*A*x*exp(2*I*c) - I*A*exp(-2*I*d*x)/(2*d) + 5
*I*B*x*exp(2*I*c) + B*exp(-2*I*d*x)/(2*d), Ne(d, 0)), (x*(3*A*exp(2*I*c) - A + 5*I*B*exp(2*I*c) - I*B), True))
*exp(-2*I*c)/(2*a) + (I*A - B)*log(exp(2*I*d*x) + exp(-2*I*c))/(a*d)

________________________________________________________________________________________

Giac [A]  time = 1.63444, size = 136, normalized size = 1.35 \begin{align*} \frac{\frac{{\left (-i \, A - B\right )} \log \left (\tan \left (d x + c\right ) + i\right )}{a} - \frac{{\left (3 i \, A - 5 \, B\right )} \log \left (-i \, \tan \left (d x + c\right ) - 1\right )}{a} - \frac{4 i \, B \tan \left (d x + c\right )}{a} - \frac{-3 i \, A \tan \left (d x + c\right ) + 5 \, B \tan \left (d x + c\right ) - A - 3 i \, B}{a{\left (\tan \left (d x + c\right ) - i\right )}}}{4 \, d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c)),x, algorithm="giac")

[Out]

1/4*((-I*A - B)*log(tan(d*x + c) + I)/a - (3*I*A - 5*B)*log(-I*tan(d*x + c) - 1)/a - 4*I*B*tan(d*x + c)/a - (-
3*I*A*tan(d*x + c) + 5*B*tan(d*x + c) - A - 3*I*B)/(a*(tan(d*x + c) - I)))/d